package com.it.plic;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author げっしょく
 * @date 2021/8/8
 */
public class Demo5 {
    public static void main(String[] args) throws IOException {
        Socket s = new Socket("127.0.0.1", 10000);
        OutputStream ops = s.getOutputStream();
        ops.write("hello".getBytes());
        //ops.close  如果在这里关流会导致整个socket都无法使用
        s.shutdownOutput();
        InputStream ips = s.getInputStream();
        InputStreamReader isr = new InputStreamReader(ips);
        BufferedReader bufferedReader = new BufferedReader(isr);
        String line;
        while ((line = bufferedReader.readLine()) != null){
            System.out.println(line);
        }

    }
}
